package com.zw.admin.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.zw.admin.server.model.PSupplier;

@Mapper
public interface PSupplierDao {

    @Select("select * from p_supplier t where t.id = #{id}")
    PSupplier getById(Long id);

    @Delete("delete from p_supplier where id = #{id}")
    int delete(Long id);

    int update(PSupplier pSupplier);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into p_supplier(supplier_no, supplier_name, region_code, address, contacts, tel, sup_type, createTime, updateTime) values(#{supplierNo}, #{supplierName}, #{regionCode}, #{address}, #{contacts}, #{tel}, #{supType}, #{createTime}, #{updateTime})")
    int save(PSupplier pSupplier);
    
    int count(@Param("params") Map<String, Object> params);

    List<PSupplier> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
